import os
import numpy as np
import binascii


def save(root_path, dir_name, save_name, data):
    save_path = os.path.join(root_path, dir_name, save_name)
    os.system("mkdir -p %s " % (os.path.dirname(save_path)))
    np.save(save_path, data)

def save_npz(root_path, dir_name, save_name, data):
    save_path = os.path.join(root_path, dir_name, save_name)
    os.system("mkdir -p %s " % (os.path.dirname(save_path)))
    np.savez_compressed(save_path, data)

def is_gzip_file(file_path):
    with open(file_path, 'rb') as file:
        header = file.read(2)
    hex_header = binascii.hexlify(header).decode('utf-8')
    if hex_header == '1f8b':
        return True
    else:
        return False
    